include(`fft_cmn_v2.m4')

il_cs_2_0

dcl_num_thread_per_group 64

dcl_literal l0, 0, 1, -1, 16

dcl_literal l1, 0.0, 1.0, -1.0, 0.707106781186547524401
dcl_literal l10, 0.9238795325112867,-0.3826834323650898, 0.7071067811865476,-0.7071067811865475
dcl_literal l11, 0.38268343236508984,-0.9238795325112867, -0.3826834323650897,-0.9238795325112867
dcl_literal l12, -0.7071067811865475,-0.7071067811865476, -0.9238795325112867,-0.3826834323650899
dcl_literal l13, 0.9807852804032304,-0.19509032201612825, 0.9238795325112867,-0.3826834323650898
dcl_literal l14, 0.8314696123025452,-0.5555702330196022, 0.7071067811865476,-0.7071067811865475
dcl_literal l15, 0.5555702330196023,-0.8314696123025452, 0.38268343236508984,-0.9238795325112867
dcl_literal l16, 0.19509032201612833,-0.9807852804032304, 0.8314696123025452,-0.5555702330196022
dcl_literal l17, 0.38268343236508984,-0.9238795325112867, -0.1950903220161282,-0.9807852804032304
dcl_literal l18, -0.7071067811865475,-0.7071067811865476, -0.9807852804032304,-0.1950903220161286
dcl_literal l19, -0.9238795325112868,0.38268343236508967, -0.5555702330196022,0.8314696123025452

dcl_literal l30, 11, 5, 512, 8
	
ishl r90.x___, vTGroupid.x, l30.x
iadd r80.x___, vTid.x, r90.x	
call 6

FFT_32_ARRAY(400, 1, 0, r100, r101)

ishl r90._y__, vTid.x, l30.y
iadd r80.x___, r90.x, r90.y
call 7

endmain

;
; Read in 32 float2 data
;
func 6
    mov r80.y, r80.x
generalForLoop(`ID', 0, 7, +1, `dnl
    mov r`'eval(400+ID), g[r80.y+eval(ID*64)]
')

    iadd r80._y__, r80.y, l30.z
generalForLoop(`ID', 0, 7, +1, `dnl
    mov r`'eval(408+ID), g[r80.y+eval(ID*64)]
')
	
    iadd r80._y__, r80.y, l30.z
generalForLoop(`ID', 0, 7, +1, `dnl
    mov r`'eval(416+ID), g[r80.y+eval(ID*64)]
')
	
    iadd r80._y__, r80.y, l30.z
generalForLoop(`ID', 0, 7, +1, `dnl
    mov r`'eval(424+ID), g[r80.y+eval(ID*64)]
')

ret
endfunc

;
; Write out 32 float2 data
;
func 7

generalForLoop(`ID', 0, 31, +1, `dnl
    mov g[r80.x+ID], r`'eval(400+REV_BITS_32(ID))
')

ret
endfunc

end
